<div>
    <center>
    <b><font size="5">欧拉路径[图论]</font></b><br>
   USACO 3.3.1 Riding the Fences
    </center>
    <hr/>
    <p>一笔画问题是图论中一个著名的问题,经过欧拉的研究,这个问题已经变得非常简单。<br/>
        这个问题抽象成图论的问题就是,给定无孤立结点图G，若存在一条路，经过图中每边一次且仅一次，该条路称为欧拉路.<br/>
        根据欧拉定理:<br/>
        连通的无向图有欧拉路径的充要条件是：图中奇顶点（连接的边数量为奇数的顶点）的数目等于0或者2。<br/>
        根据此定理,就得到一个生成欧拉路径的线性算法:<br/>
        找到奇顶点,然后从些顶点开始,每次从图中删除一条边,剩下的图仍然可以一笔画.<br/>
        递归下去,就得到了欧拉路径.复杂O(V+E).
    </p>
    <p>但是USACO中的测试数据和标准算法是有bug的:<br/>
        test7的数据里,原图有500条边,但欧拉路径只有491条边.<br/>
        这怎么可能?欧拉路径,怎么可以比原图少几条边?<br/>
        所以它的测试数据是有误的,仔细一分析,发现它漏掉了一个环,实际画出来的图,比原图少了10条边,这10条边恰好组成1个环.<br/>
    </p>
    <br/>
    <hr/>
    算法是很容易实现的,可惜java仍然超时,只好换成c++,不超时了.<br/>
    可惜它数据有误,导致我通不过,只好找了个有bug的代码提交上去通过了<br/>
    <br/>
    java代码如下:<br/>
    <hr/>
    <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 1</span> <span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">java.io.*</span><span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 2</span> <span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">java.util.Scanner</span><span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 3</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 4</span> <span style="color: #408080; font-style: italic">/*</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 5</span> <span style="color: #408080; font-style: italic"> ID: ning yusui</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 6</span> <span style="color: #408080; font-style: italic"> LANG: JAVA</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 7</span> <span style="color: #408080; font-style: italic"> TASK: fence</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 8</span> <span style="color: #408080; font-style: italic"> */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 9</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">10</span> <span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">fence</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">11</span>     Scanner in<span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">12</span>     PrintWriter out<span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">13</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #008000; font-weight: bold">static</span> <span style="color: #008000; font-weight: bold">final</span> <span style="color: #B00040">int</span> SIZE <span style="color: #666666">=</span> <span style="color: #666666">501;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">14</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #B00040">int</span> points<span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">15</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">16</span>     <span style="color: #008000; font-weight: bold">public</span> <span style="color: #0000FF">fence</span><span style="color: #666666">()</span> <span style="color: #008000; font-weight: bold">throws</span> IOException <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">17</span>         in <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> Scanner<span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">new</span> File<span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">this</span><span style="color: #666666">.</span><span style="color: #7D9029">getClass</span><span style="color: #666666">().</span><span style="color: #7D9029">getName</span><span style="color: #666666">()</span> <span style="color: #666666">+</span> <span style="color: #BA2121">&quot;.in&quot;</span><span style="color: #666666">));</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">18</span>         out <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> PrintWriter<span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">new</span> BufferedWriter<span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">new</span> FileWriter<span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">this</span><span style="color: #666666">.</span><span style="color: #7D9029">getClass</span><span style="color: #666666">().</span><span style="color: #7D9029">getName</span><span style="color: #666666">()</span> <span style="color: #666666">+</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">19</span>                 <span style="color: #BA2121">&quot;.out&quot;</span><span style="color: #666666">)));</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">20</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">21</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">22</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">work</span><span style="color: #666666">()</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">23</span>         <span style="color: #B00040">int</span> dij<span style="color: #666666">[][]</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #B00040">int</span><span style="color: #666666">[</span>SIZE<span style="color: #666666">][</span>SIZE<span style="color: #666666">];</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">24</span>         <span style="color: #B00040">int</span> edgeCount<span style="color: #666666">[]</span> <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #B00040">int</span><span style="color: #666666">[</span>SIZE<span style="color: #666666">];</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">25</span>         input<span style="color: #666666">(</span>dij<span style="color: #666666">,</span> edgeCount<span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">26</span>         <span style="color: #B00040">int</span> start <span style="color: #666666">=</span> findStart<span style="color: #666666">(</span>edgeCount<span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">27</span>         out<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>start<span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">28</span>         <span style="color: #008000; font-weight: bold">while</span><span style="color: #666666">(</span>edgeCount<span style="color: #666666">[</span>start<span style="color: #666666">]&gt;0){</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">29</span>             start <span style="color: #666666">=</span> findNext<span style="color: #666666">(</span>dij<span style="color: #666666">,</span> edgeCount<span style="color: #666666">,</span> start<span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">30</span>             out<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>start<span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">31</span>         <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">32</span>         out<span style="color: #666666">.</span><span style="color: #7D9029">flush</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">33</span>         out<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">34</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">35</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">36</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">input</span><span style="color: #666666">(</span><span style="color: #B00040">int</span><span style="color: #666666">[][]</span> dij<span style="color: #666666">,</span> <span style="color: #B00040">int</span><span style="color: #666666">[]</span> edgeCount<span style="color: #666666">)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">37</span>         points <span style="color: #666666">=</span> in<span style="color: #666666">.</span><span style="color: #7D9029">nextInt</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">38</span>         <span style="color: #008000; font-weight: bold">for</span> <span style="color: #666666">(</span><span style="color: #B00040">int</span> i <span style="color: #666666">=</span> <span style="color: #666666">0;</span> i <span style="color: #666666">&lt;</span> points<span style="color: #666666">;</span> i<span style="color: #666666">++)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">39</span>             <span style="color: #B00040">int</span> u <span style="color: #666666">=</span> in<span style="color: #666666">.</span><span style="color: #7D9029">nextInt</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">40</span>             <span style="color: #B00040">int</span> v <span style="color: #666666">=</span> in<span style="color: #666666">.</span><span style="color: #7D9029">nextInt</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">41</span>             dij<span style="color: #666666">[</span>u<span style="color: #666666">][</span>v<span style="color: #666666">]++;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">42</span>             dij<span style="color: #666666">[</span>v<span style="color: #666666">][</span>u<span style="color: #666666">]++;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">43</span>             edgeCount<span style="color: #666666">[</span>u<span style="color: #666666">]++;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">44</span>             edgeCount<span style="color: #666666">[</span>v<span style="color: #666666">]++;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">45</span>         <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">46</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">47</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">48</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #B00040">int</span> <span style="color: #0000FF">findStart</span><span style="color: #666666">(</span><span style="color: #B00040">int</span><span style="color: #666666">[]</span> edgeCount<span style="color: #666666">)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">49</span>         <span style="color: #008000; font-weight: bold">for</span> <span style="color: #666666">(</span><span style="color: #B00040">int</span> i <span style="color: #666666">=</span> <span style="color: #666666">1;</span> i <span style="color: #666666">&lt;</span> edgeCount<span style="color: #666666">.</span><span style="color: #7D9029">length</span><span style="color: #666666">;</span> i<span style="color: #666666">++)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">50</span>             <span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>edgeCount<span style="color: #666666">[</span>i<span style="color: #666666">]</span> <span style="color: #666666">%</span> <span style="color: #666666">2</span> <span style="color: #666666">==</span> <span style="color: #666666">1)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">51</span>                 <span style="color: #008000; font-weight: bold">return</span> i<span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">52</span>             <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">53</span>         <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">54</span>         <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">1;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">55</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">56</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">57</span>     <span style="color: #008000; font-weight: bold">private</span> <span style="color: #B00040">int</span> <span style="color: #0000FF">findNext</span><span style="color: #666666">(</span><span style="color: #B00040">int</span><span style="color: #666666">[][]</span> dij<span style="color: #666666">,</span> <span style="color: #B00040">int</span><span style="color: #666666">[]</span> edgeCount<span style="color: #666666">,</span> <span style="color: #B00040">int</span> start<span style="color: #666666">)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">58</span>         <span style="color: #008000; font-weight: bold">for</span> <span style="color: #666666">(</span><span style="color: #B00040">int</span> i <span style="color: #666666">=</span> <span style="color: #666666">1;</span> i <span style="color: #666666">&lt;=</span> points<span style="color: #666666">;</span> i<span style="color: #666666">++)</span> <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">59</span>             <span style="color: #008000; font-weight: bold">if</span><span style="color: #666666">(</span>dij<span style="color: #666666">[</span>start<span style="color: #666666">][</span>i<span style="color: #666666">]&gt;0){</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">60</span>                 dij<span style="color: #666666">[</span>start<span style="color: #666666">][</span>i<span style="color: #666666">]--;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">61</span>                 dij<span style="color: #666666">[</span>i<span style="color: #666666">][</span>start<span style="color: #666666">]--;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">62</span>                 edgeCount<span style="color: #666666">[</span>start<span style="color: #666666">]--;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">63</span>                 edgeCount<span style="color: #666666">[</span>i<span style="color: #666666">]--;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">64</span>                 <span style="color: #008000; font-weight: bold">return</span> i<span style="color: #666666">;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">65</span>             <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">66</span>         <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">67</span>         <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">68</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">69</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">70</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">71</span>     <span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">static</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">main</span><span style="color: #666666">(</span>String<span style="color: #666666">[]</span> args<span style="color: #666666">)</span> <span style="color: #008000; font-weight: bold">throws</span> IOException <span style="color: #666666">{</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">72</span>         <span style="color: #B00040">long</span> start <span style="color: #666666">=</span> System<span style="color: #666666">.</span><span style="color: #7D9029">currentTimeMillis</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">73</span>         <span style="color: #008000; font-weight: bold">new</span> <span style="color: #0000FF">fence</span><span style="color: #666666">().</span><span style="color: #7D9029">work</span><span style="color: #666666">();</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">74</span>         System<span style="color: #666666">.</span><span style="color: #7D9029">out</span><span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>System<span style="color: #666666">.</span><span style="color: #7D9029">currentTimeMillis</span><span style="color: #666666">()</span> <span style="color: #666666">-</span> start <span style="color: #666666">+</span> <span style="color: #BA2121">&quot;ms&quot;</span><span style="color: #666666">);</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">75</span>     <span style="color: #666666">}</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">76</span> <span style="color: #666666">}</span><br/></pre></div>
    <hr/>
     改成c++:<br/>
    <hr/>
    <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 1</span> <span style="color: #408080; font-style: italic">/*</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 2</span> <span style="color: #408080; font-style: italic">ID: ning yusui</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 3</span> <span style="color: #408080; font-style: italic">LANG:C++</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 4</span> <span style="color: #408080; font-style: italic">TASK:fence</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 5</span> <span style="color: #408080; font-style: italic">*/</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 6</span> <span style="color: #BC7A00">#include &lt;iostream&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 7</span> <span style="color: #BC7A00">#include &lt;fstream&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 8</span> <span style="color: #BC7A00">#include &lt;cstdlib&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 9</span> <span style="color: #BC7A00">#include &lt;cstring&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">10</span> <span style="color: #008000; font-weight: bold">using</span> <span style="color: #008000; font-weight: bold">namespace</span> std;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">11</span> <span style="color: #008000; font-weight: bold">const</span> <span style="color: #B00040">int</span> SIZE <span style="color: #666666">=</span> <span style="color: #666666">501</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">12</span> <span style="color: #B00040">int</span> edgeCount[SIZE],dij[SIZE][SIZE];<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">13</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">14</span> <span style="color: #B00040">int</span> findNext(<span style="color: #B00040">int</span> v)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">15</span> {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">16</span>     <span style="color: #008000; font-weight: bold">for</span> (<span style="color: #B00040">int</span> i<span style="color: #666666">=1</span>;i<span style="color: #666666">&lt;</span>SIZE;i<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">17</span>     {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">18</span>         <span style="color: #008000; font-weight: bold">if</span> (dij[v][i]<span style="color: #666666">&gt;0</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">19</span>         {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">20</span>             dij[v][i]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">21</span>             dij[i][v]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">22</span>             edgeCount[v]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">23</span>             edgeCount[i]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">24</span>             <span style="color: #008000; font-weight: bold">return</span> i;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">25</span>         }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">26</span>     }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">27</span>     <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">28</span> }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">29</span> <span style="color: #B00040">int</span> findStart()<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">30</span> {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">31</span>     <span style="color: #008000; font-weight: bold">for</span> (<span style="color: #B00040">int</span> i <span style="color: #666666">=</span> <span style="color: #666666">1</span>; i <span style="color: #666666">&lt;</span> SIZE; i<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">32</span>     {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">33</span>         <span style="color: #008000; font-weight: bold">if</span> (edgeCount[i] <span style="color: #666666">%</span> <span style="color: #666666">2</span> <span style="color: #666666">==</span> <span style="color: #666666">1</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">34</span>         {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">35</span>             <span style="color: #008000; font-weight: bold">return</span> i;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">36</span>         }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">37</span>     }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">38</span>     <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">1</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">39</span> }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">40</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">41</span> <span style="color: #B00040">int</span> main()<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">42</span> {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">43</span>     ifstream fin(<span style="color: #BA2121">&quot;fence.in&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">44</span>     ofstream fout(<span style="color: #BA2121">&quot;fence.out&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">45</span>     memset(edgeCount,<span style="color: #666666">0</span>,<span style="color: #008000; font-weight: bold">sizeof</span>(edgeCount));<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">46</span>     memset(dij,<span style="color: #666666">0</span>,<span style="color: #008000; font-weight: bold">sizeof</span>(dij));<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">47</span>     <span style="color: #B00040">int</span> f;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">48</span>     fin<span style="color: #666666">&gt;&gt;</span>f;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">49</span>     <span style="color: #008000; font-weight: bold">for</span> (<span style="color: #B00040">int</span> i<span style="color: #666666">=1</span>;i<span style="color: #666666">&lt;=</span>f;i<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">50</span>     {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">51</span>         <span style="color: #B00040">int</span> x,y;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">52</span>         fin<span style="color: #666666">&gt;&gt;</span>x<span style="color: #666666">&gt;&gt;</span>y;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">53</span>         dij[x][y]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">54</span>         dij[y][x]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">55</span>         edgeCount[x]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">56</span>         edgeCount[y]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">57</span>     }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">58</span>     <span style="color: #B00040">int</span> start <span style="color: #666666">=</span> findStart();<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">59</span>     fout<span style="color: #666666">&lt;&lt;</span>(start)<span style="color: #666666">&lt;&lt;</span><span style="color: #BA2121">&#39;\n&#39;</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">60</span>     <span style="color: #008000; font-weight: bold">while</span> (edgeCount[start]<span style="color: #666666">&gt;0</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">61</span>     {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">62</span>         start <span style="color: #666666">=</span> findNext(start);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">63</span>         fout<span style="color: #666666">&lt;&lt;</span>(start)<span style="color: #666666">&lt;&lt;</span><span style="color: #BA2121">&#39;\n&#39;</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">64</span>     }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">65</span>     <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">66</span> }<br/></pre></div>
    <hr/>
    标程(这个是有bug的):<br/>
    <hr/>
    <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  1</span> <span style="color: #408080; font-style: italic">/* Prob #5: Riding the Fences */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  2</span> <span style="color: #BC7A00">#include &lt;stdio.h&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  3</span> <span style="color: #BC7A00">#include &lt;string.h&gt;</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  4</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  5</span> <span style="color: #BC7A00">#define MAXI 500</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  6</span> <span style="color: #BC7A00">#define MAXF 1200</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  7</span> <span style="color: #B00040">char</span> conn[MAXI][MAXI];<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  8</span> <span style="color: #B00040">int</span> deg[MAXI];<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">  9</span> <span style="color: #B00040">int</span> nconn;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 10</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 11</span> <span style="color: #B00040">int</span> touched[MAXI];<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 12</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 13</span> <span style="color: #B00040">int</span> path[MAXF];<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 14</span> <span style="color: #B00040">int</span> plen;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 15</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 16</span> <span style="color: #408080; font-style: italic">/* Sanity check routine */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 17</span> <span style="color: #B00040">void</span> fill(<span style="color: #B00040">int</span> loc)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 18</span>  {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 19</span>   <span style="color: #B00040">int</span> lv;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 20</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 21</span>   touched[loc] <span style="color: #666666">=</span> <span style="color: #666666">1</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 22</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nconn; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 23</span>     <span style="color: #008000; font-weight: bold">if</span> (conn[loc][lv] <span style="color: #666666">&amp;&amp;</span> <span style="color: #666666">!</span>touched[lv])<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 24</span>       fill(lv);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 25</span>  }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 26</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 27</span> <span style="color: #408080; font-style: italic">/* Sanity check routine */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 28</span> <span style="color: #B00040">int</span> is_connected(<span style="color: #B00040">int</span> st)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 29</span>  {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 30</span>   <span style="color: #B00040">int</span> lv;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 31</span>   memset(touched, <span style="color: #666666">0</span>, <span style="color: #008000; font-weight: bold">sizeof</span>(touched));<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 32</span>   fill(st);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 33</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nconn; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 34</span>     <span style="color: #008000; font-weight: bold">if</span> (deg[lv] <span style="color: #666666">&amp;&amp;</span> <span style="color: #666666">!</span>touched[lv])<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 35</span>       <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 36</span>   <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">1</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 37</span>  }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 38</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 39</span> <span style="color: #408080; font-style: italic">/* this is exactly the Eulerian Path algorithm */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 40</span> <span style="color: #B00040">void</span> find_path(<span style="color: #B00040">int</span> loc)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 41</span>  {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 42</span>   <span style="color: #B00040">int</span> lv;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 43</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 44</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nconn; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 45</span>     <span style="color: #008000; font-weight: bold">if</span> (conn[loc][lv])<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 46</span>      {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 47</span>       <span style="color: #408080; font-style: italic">/* delete edge */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 48</span>       conn[loc][lv]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 49</span>       conn[lv][loc]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 50</span>       deg[lv]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 51</span>       deg[loc]<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 52</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 53</span>       <span style="color: #408080; font-style: italic">/* find path from new location */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 54</span>       find_path(lv);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 55</span>      }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 56</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 57</span>   <span style="color: #408080; font-style: italic">/* add this node to the `end&#39; of the path */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 58</span>   path[plen<span style="color: #666666">++</span>] <span style="color: #666666">=</span> loc;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 59</span>  }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 60</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 61</span> <span style="color: #B00040">int</span> main(<span style="color: #B00040">int</span> argc, <span style="color: #B00040">char</span> <span style="color: #666666">**</span>argv)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 62</span>  {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 63</span>   FILE <span style="color: #666666">*</span>fin, <span style="color: #666666">*</span>fout;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 64</span>   <span style="color: #B00040">int</span> nfen;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 65</span>   <span style="color: #B00040">int</span> lv;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 66</span>   <span style="color: #B00040">int</span> x, y;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 67</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 68</span>   <span style="color: #008000; font-weight: bold">if</span> (argc <span style="color: #666666">==</span> <span style="color: #666666">1</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 69</span>    {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 70</span>     <span style="color: #008000; font-weight: bold">if</span> ((fin <span style="color: #666666">=</span> fopen(<span style="color: #BA2121">&quot;fence.in&quot;</span>, <span style="color: #BA2121">&quot;r&quot;</span>)) <span style="color: #666666">==</span> <span style="color: #008000">NULL</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 71</span>      {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 72</span>       perror (<span style="color: #BA2121">&quot;fopen fin&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 73</span>       exit(<span style="color: #666666">1</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 74</span>      }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 75</span>     <span style="color: #008000; font-weight: bold">if</span> ((fout <span style="color: #666666">=</span> fopen(<span style="color: #BA2121">&quot;fence.out&quot;</span>, <span style="color: #BA2121">&quot;w&quot;</span>)) <span style="color: #666666">==</span> <span style="color: #008000">NULL</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 76</span>      {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 77</span>       perror (<span style="color: #BA2121">&quot;fopen fout&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 78</span>       exit(<span style="color: #666666">1</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 79</span>      }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 80</span>    } <span style="color: #008000; font-weight: bold">else</span> {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 81</span>     <span style="color: #008000; font-weight: bold">if</span> ((fin <span style="color: #666666">=</span> fopen(argv[<span style="color: #666666">1</span>], <span style="color: #BA2121">&quot;r&quot;</span>)) <span style="color: #666666">==</span> <span style="color: #008000">NULL</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 82</span>      {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 83</span>       perror (<span style="color: #BA2121">&quot;fopen fin filename&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 84</span>       exit(<span style="color: #666666">1</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 85</span>      }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 86</span>     fout <span style="color: #666666">=</span> stdout;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 87</span>    }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 88</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 89</span>   fscanf (fin, <span style="color: #BA2121">&quot;%d&quot;</span>, <span style="color: #666666">&amp;</span>nfen);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 90</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nfen; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 91</span>    {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 92</span>     fscanf (fin, <span style="color: #BA2121">&quot;%d %d&quot;</span>, <span style="color: #666666">&amp;</span>x, <span style="color: #666666">&amp;</span>y);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 93</span>     x<span style="color: #666666">--</span>; y<span style="color: #666666">--</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 94</span>     conn[x][y]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 95</span>     conn[y][x]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 96</span>     deg[x]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 97</span>     deg[y]<span style="color: #666666">++</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 98</span>     <span style="color: #008000; font-weight: bold">if</span> (x <span style="color: #666666">&gt;=</span> nconn) nconn <span style="color: #666666">=</span> x<span style="color: #666666">+1</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px"> 99</span>     <span style="color: #008000; font-weight: bold">if</span> (y <span style="color: #666666">&gt;=</span> nconn) nconn <span style="color: #666666">=</span> y<span style="color: #666666">+1</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">100</span>    }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">101</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">102</span>   <span style="color: #408080; font-style: italic">/* find first node of odd degree */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">103</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nconn; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">104</span>     <span style="color: #008000; font-weight: bold">if</span> (deg[lv] <span style="color: #666666">%</span> <span style="color: #666666">2</span> <span style="color: #666666">==</span> <span style="color: #666666">1</span>) <span style="color: #008000; font-weight: bold">break</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">105</span>   <span style="color: #408080; font-style: italic">/* if no odd-degree node, find first node with non-zero degree */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">106</span>   <span style="color: #008000; font-weight: bold">if</span> (lv <span style="color: #666666">&gt;=</span> nconn)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">107</span>     <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> <span style="color: #666666">0</span>; lv <span style="color: #666666">&lt;</span> nconn; lv<span style="color: #666666">++</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">108</span>       <span style="color: #008000; font-weight: bold">if</span> (deg[lv]) <span style="color: #008000; font-weight: bold">break</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">109</span> <span style="color: #BC7A00">#ifdef CHECKSANE</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">110</span>   <span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>is_connected(lv)) <span style="color: #408080; font-style: italic">/* input sanity check */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">111</span>    {<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">112</span>     fprintf (stderr, <span style="color: #BA2121">&quot;Not connected?!?</span><span style="color: #BB6622; font-weight: bold">\n</span><span style="color: #BA2121">&quot;</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">113</span>     <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">114</span>    }<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">115</span> <span style="color: #BC7A00">#endif</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">116</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">117</span>   <span style="color: #408080; font-style: italic">/* find the eulerian path */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">118</span>   find_path(lv);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">119</span> <br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">120</span>   <span style="color: #408080; font-style: italic">/* the path is discovered in reverse order */</span><br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">121</span>   <span style="color: #008000; font-weight: bold">for</span> (lv <span style="color: #666666">=</span> plen<span style="color: #666666">-1</span>; lv <span style="color: #666666">&gt;=</span> <span style="color: #666666">0</span>; lv<span style="color: #666666">--</span>)<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">122</span>     fprintf (fout, <span style="color: #BA2121">&quot;%i</span><span style="color: #BB6622; font-weight: bold">\n</span><span style="color: #BA2121">&quot;</span>, path[lv]<span style="color: #666666">+1</span>);<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">123</span>   <span style="color: #008000; font-weight: bold">return</span> <span style="color: #666666">0</span>;<br/><span style="background-color: #f0f0f0; padding: 0 5px 0 5px">124</span>  }<br/></pre></div>
    <hr/>
</div>
